home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / turbo.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  27KB  |  712 lines

  1. /*************************************************************************
  2.  
  3.     Turbo - Sega - 1981
  4.  
  5. driver by Alex Pasadyn, Howie Cohen, Frank Palazzolo, Aaron Giles, Ernesto Corvi
  6.  
  7.  
  8.     Memory Map:  ( * not complete * )
  9.  
  10.     Address Range:    R/W:     Function:
  11.     --------------------------------------------------------------------------
  12.     0000 - 5fff        R         Program ROM
  13.     a000 - a0ff        W         Sprite RAM
  14.     a800 - a803        W         Lamps / Coin Meters
  15.     b000 - b1ff        R/W         Collision RAM
  16.     e000 - e7ff        R/W         character RAM
  17.     f000 - f7ff        R/W         RAM
  18.     f202                     coinage 2
  19.     f205                     coinage 1
  20.     f800 - f803        R/W         road drawing
  21.     f900 - f903        R/W         road drawing
  22.     fa00 - fa03        R/W         sound
  23.     fb00 - fb03        R/W         x,DS2,x,x
  24.     fc00 - fc01        R         DS1,x
  25.     fc00 - fc01        W         score
  26.     fd00            R         Coin Inputs, etc.
  27.     fe00            R         DS3,x
  28.  
  29.  Switch settings:
  30.  Notes:
  31.         1) Facing the CPU board, with the two large IDC connectors at
  32.            the top of the board, and the large and small IDC
  33.            connectors at the bottom, DIP switch #1 is upper right DIP
  34.            switch, DIP switch #2 is the DIP switch to the right of it.
  35.  
  36.         2) Facing the Sound board, with the IDC connector at the
  37.            bottom of the board, DIP switch #3 (4 bank) can be seen.
  38.  ----------------------------------------------------------------------------
  39.  
  40.  Option       (DIP Swtich #1) | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 | SW7 | SW8 |
  41.  --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
  42.  1 Car On Extended Play       | ON     | ON  |     |       |     |       |     |       |
  43.  2 Car On Extended Play       | OFF | ON  |     |       |     |       |     |       |
  44.  3 Car On Extended Play       | ON     | OFF |     |       |     |       |     |       |
  45.  4 Car On Extended Play       | OFF | OFF |     |       |     |       |     |       |
  46.  --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
  47.  Game Time Adjustable       |     |       | ON     |       |     |       |     |       |
  48.  Game Time Fixed (55 Sec.) |     |       | OFF |       |     |       |     |       |
  49.  --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
  50.  Hard Game Difficulty       |     |       |     | ON  |     |       |     |       |
  51.  Easy Game Difficulty       |     |       |     | OFF |     |       |     |       |
  52.  --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
  53.  Normal Game Mode           |     |       |     |       | ON     |       |     |       |
  54.  No Collisions (cheat)       |     |       |     |       | OFF |       |     |       |
  55.  --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
  56.  Initial Entry Off (?)       |     |       |     |       |     | ON  |     |       |
  57.  Initial Entry On  (?)       |     |       |     |       |     | OFF |     |       |
  58.  --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
  59.  Not Used                   |     |       |     |       |     |       |  X     |    X  |
  60.  ---------------------------------------------------------------------------
  61.  
  62.  Option       (DIP Swtich #2) | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 | SW7 | SW8 |
  63.  --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
  64.  60 Seconds Game Time       | ON     | ON  |     |       |     |       |     |       |
  65.  70 Seconds Game Time       | OFF | ON  |     |       |     |       |     |       |
  66.  80 Seconds Game Time       | ON     | OFF |     |       |     |       |     |       |
  67.  90 Seconds Game Time       | OFF | OFF |     |       |     |       |     |       |
  68.  --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
  69.  Slot 1     1 Coin     1 Credit  |     |       | ON     | ON  | ON     |       |     |       |
  70.  Slot 1     1 Coin     2 Credits |     |       | OFF | ON  | ON     |       |     |       |
  71.  Slot 1     1 Coin     3 Credits |     |       | ON     | OFF | ON     |       |     |       |
  72.  Slot 1     1 Coin     6 Credits |     |       | OFF | OFF | ON     |       |     |       |
  73.  Slot 1     2 Coins 1 Credit  |     |       | ON     | ON  | OFF |       |     |       |
  74.  Slot 1     3 Coins 1 Credit  |     |       | OFF | ON  | OFF |       |     |       |
  75.  Slot 1     4 Coins 1 Credit  |     |       | ON     | OFF | OFF |       |     |       |
  76.  Slot 1     1 Coin     1 Credit  |     |       | OFF | OFF | OFF |       |     |       |
  77.  --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
  78.  Slot 2     1 Coin     1 Credit  |     |       |     |       |     | ON  | ON     | ON  |
  79.  Slot 2     1 Coin     2 Credits |     |       |     |       |     | OFF | ON     | ON  |
  80.  Slot 2     1 Coin     3 Credits |     |       |     |       |     | ON  | OFF | ON  |
  81.  Slot 2     1 Coin     6 Credits |     |       |     |       |     | OFF | OFF | ON  |
  82.  Slot 2     2 Coins 1 Credit  |     |       |     |       |     | ON  | ON     | OFF |
  83.  Slot 2     3 Coins 1 Credit  |     |       |     |       |     | OFF | ON     | OFF |
  84.  Slot 2     4 Coins 1 Credit  |     |       |     |       |     | ON  | OFF | OFF |
  85.  Slot 2     1 Coins 1 Credit  |     |       |     |       |     | OFF | OFF | OFF |
  86.  ---------------------------------------------------------------------------
  87.  
  88.  Option       (DIP Swtich #3) | SW1 | SW2 | SW3 | SW4 |
  89.  --------------------------|-----|-----|-----|-----|
  90.  Not Used                   |  X     |    X  |     |       |
  91.  --------------------------|-----|-----|-----|-----|
  92.  Digital (LED) Tachometer  |     |       | ON     |       |
  93.  Analog (Meter) Tachometer |     |       | OFF |       |
  94.  --------------------------|-----|-----|-----|-----|
  95.  Cockpit Sound System       |     |       |     | ON  |
  96.  Upright Sound System       |     |       |     | OFF |
  97. ---------------------------------------------------
  98.  
  99. Here is a complete list of the ROMs:
  100.  
  101.     Turbo ROMLIST - Frank Palazzolo
  102.     Name     Loc             Function
  103.     -----------------------------------------------------------------------------
  104.     Images Acquired:
  105.     EPR1262,3,4     IC76, IC89, IC103
  106.     EPR1363,4,5
  107.     EPR15xx                Program ROMS
  108.     EPR1244                Character Data 1
  109.     EPR1245                Character Data 2
  110.     EPR-1125            Road ROMS
  111.     EPR-1126
  112.     EPR-1127
  113.     EPR-1238
  114.     EPR-1239
  115.     EPR-1240
  116.     EPR-1241
  117.     EPR-1242
  118.     EPR-1243
  119.     EPR1246-1258        Sprite ROMS
  120.     EPR1288-1300
  121.  
  122.     PR-1114        IC13    Color 1 (road, etc.)
  123.     PR-1115        IC18    Road gfx
  124.     PR-1116        IC20    Crash (collision detection?)
  125.     PR-1117        IC21    Color 2 (road, etc.)
  126.     PR-1118        IC99    256x4 Character Color PROM
  127.     PR-1119        IC50    512x8 Vertical Timing PROM
  128.     PR-1120        IC62    Horizontal Timing PROM
  129.     PR-1121        IC29    Color PROM
  130.     PR-1122        IC11    Pattern 1
  131.     PR-1123        IC21    Pattern 2
  132.  
  133.     PA-06R        IC22    Mathbox Timing PAL
  134.     PA-06L        IC90    Address Decode PAL
  135.  
  136. **************************************************************************/
  137.  
  138. #include "driver.h"
  139. #include "vidhrdw/generic.h"
  140. #include "machine/8255ppi.h"
  141.  
  142. /* from machine */
  143. void turbo_init_machine(void);
  144. READ_HANDLER( turbo_8279_r );
  145. READ_HANDLER( turbo_collision_r );
  146. WRITE_HANDLER( turbo_8279_w );
  147. WRITE_HANDLER( turbo_coin_and_lamp_w );
  148.  
  149. /* from vidhrdw */
  150. extern UINT8 *turbo_sprite_position;
  151.  
  152. int turbo_vh_start(void);
  153. void turbo_vh_stop(void);
  154. void turbo_vh_convert_color_prom(UINT8 *palette, UINT16 *colortable, const UINT8 *color_prom);
  155. void turbo_vh_eof(void);
  156. void turbo_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh);
  157. WRITE_HANDLER( turbo_collision_clear_w );
  158.  
  159.  
  160. /*********************************************************************
  161.  * CPU memory structures
  162.  *********************************************************************/
  163.  
  164. static struct MemoryReadAddress readmem[] =
  165. {
  166.     { 0x0000, 0x5fff, MRA_ROM },
  167.     { 0xb000, 0xb1ff, MRA_RAM },
  168.     { 0xe000, 0xe7ff, MRA_RAM },
  169.     { 0xf000, 0xf7ff, MRA_RAM },
  170.     { 0xf800, 0xf803, ppi8255_0_r },
  171.     { 0xf900, 0xf903, ppi8255_1_r },
  172.     { 0xfa00, 0xfa03, ppi8255_2_r },
  173.     { 0xfb00, 0xfb03, ppi8255_3_r },
  174.     { 0xfc00, 0xfcff, turbo_8279_r },
  175.     { 0xfd00, 0xfdff, input_port_0_r },
  176.     { 0xfe00, 0xfeff, turbo_collision_r },
  177.     { -1 }    /* end of table */
  178. };
  179.  
  180. static struct MemoryWriteAddress writemem[] =
  181. {
  182.     { 0x0000, 0x5fff, MWA_ROM },
  183.     { 0xa000, 0xa0ff, MWA_RAM, &spriteram, &spriteram_size },
  184.     { 0xa800, 0xa807, turbo_coin_and_lamp_w },
  185.     { 0xb000, 0xb1ff, MWA_RAM, &turbo_sprite_position },
  186.     { 0xb800, 0xb800, MWA_NOP },    /* resets the analog wheel value */
  187.     { 0xe000, 0xe7ff, MWA_RAM, &videoram, &videoram_size },
  188.     { 0xe800, 0xe800, turbo_collision_clear_w },
  189.     { 0xf000, 0xf7ff, MWA_RAM },
  190.     { 0xf800, 0xf803, ppi8255_0_w },
  191.     { 0xf900, 0xf903, ppi8255_1_w },
  192.     { 0xfa00, 0xfa03, ppi8255_2_w },
  193.     { 0xfb00, 0xfb03, ppi8255_3_w },
  194.     { 0xfc00, 0xfcff, turbo_8279_w },
  195.     { -1 }    /* end of table */
  196. };
  197.  
  198.  
  199. /*********************************************************************
  200.  * Input port definitions
  201.  *********************************************************************/
  202.  
  203. INPUT_PORTS_START( turbo )
  204.     PORT_START        /* IN0 */
  205.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 )                /* ACCEL B */
  206.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 )                /* ACCEL A */
  207.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_TOGGLE )    /* SHIFT */
  208.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
  209.     PORT_SERVICE( 0x10, IP_ACTIVE_LOW )
  210.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN4 )                    /* SERVICE */
  211.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
  212.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
  213.  
  214.     PORT_START    /* DSW 1 */
  215.     PORT_DIPNAME( 0x03, 0x03, "Car On Extended Play" )
  216.     PORT_DIPSETTING( 0x03, "1" )
  217.     PORT_DIPSETTING( 0x02, "2" )
  218.     PORT_DIPSETTING( 0x01, "3" )
  219.     PORT_DIPSETTING( 0x00, "4" )
  220.     PORT_DIPNAME( 0x04, 0x04, "Game Time" )
  221.     PORT_DIPSETTING( 0x00, "Fixed (55 sec)")
  222.     PORT_DIPSETTING( 0x04, "Adjustable" )
  223.     PORT_DIPNAME( 0x08, 0x00, DEF_STR( Difficulty ) )
  224.     PORT_DIPSETTING( 0x00, "Easy")
  225.     PORT_DIPSETTING( 0x08, "Hard")
  226.     PORT_DIPNAME( 0x10, 0x00, "Game Mode" )
  227.     PORT_DIPSETTING( 0x10, "No Collisions (cheat)")
  228.     PORT_DIPSETTING( 0x00, "Normal")
  229.     PORT_DIPNAME( 0x20, 0x00, "Initial Entry" )
  230.     PORT_DIPSETTING( 0x20, DEF_STR( Off ))
  231.     PORT_DIPSETTING( 0x00, DEF_STR( On ))
  232.     PORT_BIT( 0xc0, 0xc0, IPT_UNUSED )
  233.  
  234.     PORT_START    /* DSW 2 */
  235.     PORT_DIPNAME( 0x03, 0x03, "Game Time" )
  236.     PORT_DIPSETTING( 0x00, "60 seconds" )
  237.     PORT_DIPSETTING( 0x01, "70 seconds" )
  238.     PORT_DIPSETTING( 0x02, "80 seconds" )
  239.     PORT_DIPSETTING( 0x03, "90 seconds" )
  240.     PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Coin_B ))
  241.     PORT_DIPSETTING(    0x18, DEF_STR( 4C_1C ))
  242.     PORT_DIPSETTING(    0x14, DEF_STR( 3C_1C ))
  243.     PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ))
  244. /*    PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ))*/
  245.     PORT_DIPSETTING(    0x1c, DEF_STR( 1C_1C ))
  246.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ))
  247.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_3C ))
  248.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_6C ))
  249.     PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Coin_A ))
  250.     PORT_DIPSETTING(    0xc0, DEF_STR( 4C_1C ))
  251.     PORT_DIPSETTING(    0xa0, DEF_STR( 3C_1C ))
  252.     PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ))
  253. /*    PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ))*/
  254.     PORT_DIPSETTING(    0xe0, DEF_STR( 1C_1C ))
  255.     PORT_DIPSETTING(    0x20, DEF_STR( 1C_2C ))
  256.     PORT_DIPSETTING(    0x40, DEF_STR( 1C_3C ))
  257.     PORT_DIPSETTING(    0x60, DEF_STR( 1C_6C ))
  258.  
  259.     PORT_START    /* DSW 3 */
  260.     PORT_BIT( 0x0f, 0x00, IPT_UNUSED )        /* Merged with collision bits */
  261.     PORT_BIT( 0x30, 0x00, IPT_UNUSED )
  262.     PORT_DIPNAME( 0x40, 0x40, "Tachometer" )
  263.     PORT_DIPSETTING(    0x40, "Analog (Meter)")
  264.     PORT_DIPSETTING(    0x00, "Digital (led)")
  265.     PORT_DIPNAME( 0x80, 0x80, "Sound System" )
  266.     PORT_DIPSETTING(    0x80, DEF_STR( Upright ) )
  267.     PORT_DIPSETTING(    0x00, "Cockpit")
  268.  
  269.     PORT_START        /* IN0 */
  270.     PORT_ANALOG( 0xff, 0, IPT_DIAL | IPF_CENTER, 10, 30, 0, 0 )
  271. INPUT_PORTS_END
  272.  
  273.  
  274. /*********************************************************************
  275.  * Graphics layouts
  276.  *********************************************************************/
  277.  
  278. static struct GfxLayout numlayout =
  279. {
  280.     10,8,    /* 10*8 characters */
  281.     16,        /* 16 characters */
  282.     1,        /* 1 bit per pixel */
  283.     { 0 },    /* bitplane offsets */
  284.     { 9*8, 8*8, 7*8, 6*8, 5*8, 4*8, 3*8, 2*8, 1*8, 0*8 },
  285.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  286.     10*8    /* every character uses 10 consecutive bytes */
  287. };
  288.  
  289. static struct GfxLayout tachlayout =
  290. {
  291.     16,1,    /* 16*1 characters */
  292.     2,        /* 2 characters */
  293.     1,        /* 1 bit per pixel */
  294.     { 0 },    /* bitplane offsets */
  295.     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  296.     { 0 },
  297.     1*8        /* every character uses 1 consecutive byte */
  298. };
  299.  
  300. static struct GfxLayout charlayout =
  301. {
  302.     8,8,    /* 8*8 characters */
  303.     256,    /* 256 characters */
  304.     2,        /* 2 bits per pixel */
  305.     { 256*8*8, 0 },    /* bitplane offsets */
  306.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  307.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  308.     8*8        /* every character uses 8 consecutive bytes */
  309. };
  310.  
  311. static struct GfxDecodeInfo gfxdecodeinfo[] =
  312. {
  313.     { REGION_GFX4, 0x0000, &numlayout,    512,   1 },
  314.     { REGION_GFX4, 0x0100, &tachlayout,    512,   3 },
  315.     { REGION_GFX3, 0x0000, &charlayout,    512,   3 },
  316.     { -1 }
  317. };
  318.  
  319.  
  320. /*********************************************************************
  321.  * Sound interfaces
  322.  *********************************************************************/
  323.  
  324. static const char *sample_names[]=
  325. {
  326.     "*turbo",
  327.     "01.wav",        /* Trig1 */
  328.     "02.wav",        /* Trig2 */
  329.     "03.wav",        /* Trig3 */
  330.     "04.wav",        /* Trig4 */
  331.     "05.wav",        /* Screech */
  332.     "06.wav",        /* Crash */
  333.     "skidding.wav",    /* Spin */
  334.     "idle.wav",        /* Idle */
  335.     "ambulanc.wav",    /* Ambulance */
  336.     0
  337. };
  338.  
  339. static struct Samplesinterface samples_interface =
  340. {
  341.     8,            /* eight channels */
  342.     25,            /* volume */
  343.     sample_names
  344. };
  345.  
  346.  
  347. /*********************************************************************
  348.  * Machine driver
  349.  *********************************************************************/
  350.  
  351. static struct MachineDriver machine_driver_turbo =
  352. {
  353.     /* basic machine hardware */
  354.     {
  355.         {
  356.             CPU_Z80,
  357.             5000000,
  358.             readmem,writemem,0,0,
  359.             interrupt,1
  360.         }
  361.     },
  362.     30, DEFAULT_REAL_30HZ_VBLANK_DURATION,
  363.     1,
  364.     turbo_init_machine,
  365.  
  366.     /* video hardware */
  367.     32*8, 35*8, { 1*8, 32*8-1, 0*8, 35*8-1 },
  368.     gfxdecodeinfo,
  369.     512+6,512+6,
  370.     turbo_vh_convert_color_prom,
  371.  
  372.     VIDEO_TYPE_RASTER,
  373.     turbo_vh_eof,
  374.     turbo_vh_start,
  375.     turbo_vh_stop,
  376.     turbo_vh_screenrefresh,
  377.  
  378.     /* sound hardware */
  379.     0,0,0,0,
  380.     {
  381.         {
  382.             SOUND_SAMPLES,
  383.             &samples_interface
  384.         }
  385.     }
  386. };
  387.  
  388.  
  389. /*********************************************************************
  390.  * ROM definitions
  391.  *********************************************************************/
  392.  
  393. ROM_START( turbo )
  394.     ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */
  395.     ROM_LOAD( "epr1513.bin",  0x0000, 0x2000, 0x0326adfc )
  396.     ROM_LOAD( "epr1514.bin",  0x2000, 0x2000, 0x25af63b0 )
  397.     ROM_LOAD( "epr1515.bin",  0x4000, 0x2000, 0x059c1c36 )
  398.  
  399.     ROM_REGION( 0x20000, REGION_GFX1 ) /* sprite data */
  400.     ROM_LOAD( "epr1246.rom", 0x00000, 0x2000, 0x555bfe9a )
  401.     ROM_RELOAD(                 0x02000, 0x2000 )
  402.     ROM_LOAD( "epr1247.rom", 0x04000, 0x2000, 0xc8c5e4d5 )
  403.     ROM_RELOAD(                 0x06000, 0x2000 )
  404.     ROM_LOAD( "epr1248.rom", 0x08000, 0x2000, 0x82fe5b94 )
  405.     ROM_RELOAD(                 0x0a000, 0x2000 )
  406.     ROM_LOAD( "epr1249.rom", 0x0c000, 0x2000, 0xe258e009 )
  407.     ROM_LOAD( "epr1250.rom", 0x0e000, 0x2000, 0xaee6e05e )
  408.     ROM_LOAD( "epr1251.rom", 0x10000, 0x2000, 0x292573de )
  409.     ROM_LOAD( "epr1252.rom", 0x12000, 0x2000, 0xaee6e05e )
  410.     ROM_LOAD( "epr1253.rom", 0x14000, 0x2000, 0x92783626 )
  411.     ROM_LOAD( "epr1254.rom", 0x16000, 0x2000, 0xaee6e05e )
  412.     ROM_LOAD( "epr1255.rom", 0x18000, 0x2000, 0x485dcef9 )
  413.     ROM_LOAD( "epr1256.rom", 0x1a000, 0x2000, 0xaee6e05e )
  414.     ROM_LOAD( "epr1257.rom", 0x1c000, 0x2000, 0x4ca984ce )
  415.     ROM_LOAD( "epr1258.rom", 0x1e000, 0x2000, 0xaee6e05e )
  416.  
  417.     ROM_REGION( 0x4800, REGION_GFX2 ) /* road data */
  418.     ROM_LOAD( "epr1125.rom", 0x0000, 0x0800, 0x65b5d44b )
  419.     ROM_LOAD( "epr1126.rom", 0x0800, 0x0800, 0x685ace1b )
  420.     ROM_LOAD( "epr1127.rom", 0x1000, 0x0800, 0x9233c9ca )
  421.     ROM_LOAD( "epr1238.rom", 0x1800, 0x0800, 0xd94fd83f )
  422.     ROM_LOAD( "epr1239.rom", 0x2000, 0x0800, 0x4c41124f )
  423.     ROM_LOAD( "epr1240.rom", 0x2800, 0x0800, 0x371d6282 )
  424.     ROM_LOAD( "epr1241.rom", 0x3000, 0x0800, 0x1109358a )
  425.     ROM_LOAD( "epr1242.rom", 0x3800, 0x0800, 0x04866769 )
  426.     ROM_LOAD( "epr1243.rom", 0x4000, 0x0800, 0x29854c48 )
  427.  
  428.     ROM_REGION( 0x1000, REGION_GFX3 )    /* background data */
  429.     ROM_LOAD( "epr1244.rom", 0x0000, 0x0800, 0x17f67424 )
  430.     ROM_LOAD( "epr1245.rom", 0x0800, 0x0800, 0x2ba0b46b )
  431.  
  432.     ROM_REGION( 0x200, REGION_GFX4 )    /* number data (copied at init time) */
  433.  
  434.  
  435.     ROM_REGION( 0x1000, REGION_PROMS ) /* various PROMs */
  436.     ROM_LOAD( "pr1121.bin",     0x0000, 0x0200, 0x7692f497 )    /* palette */
  437.     ROM_LOAD( "pr1122.bin",     0x0200, 0x0400, 0x1a86ce70 )    /* sprite priorities */
  438.     ROM_LOAD( "pr1123.bin",     0x0600, 0x0400, 0x02d2cb52 )    /* sprite/road/background priorities */
  439.     ROM_LOAD( "pr-1118.bin", 0x0a00, 0x0100, 0x07324cfd )    /* background color table */
  440.     ROM_LOAD( "pr1114.bin",     0x0b00, 0x0020, 0x78aded46 )    /* road red/green color table */
  441.     ROM_LOAD( "pr1117.bin",     0x0b20, 0x0020, 0xf06d9907 )    /* road green/blue color table */
  442.     ROM_LOAD( "pr1115.bin",     0x0b40, 0x0020, 0x5394092c )    /* road collision/enable */
  443.     ROM_LOAD( "pr1116.bin",     0x0b60, 0x0020, 0x3956767d )    /* collision detection */
  444.     ROM_LOAD( "sndprom.bin", 0x0b80, 0x0020, 0xb369a6ae )
  445.     ROM_LOAD( "pr-1119.bin", 0x0c00, 0x0200, 0x628d3f1d )    /* timing - not used */
  446.     ROM_LOAD( "pr-1120.bin", 0x0e00, 0x0200, 0x591b6a68 )    /* timing - not used */
  447. ROM_END
  448.  
  449. ROM_START( turboa )
  450.     ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */
  451.     ROM_LOAD( "epr1262.rom",  0x0000, 0x2000, 0x1951b83a )
  452.     ROM_LOAD( "epr1263.rom",  0x2000, 0x2000, 0x45e01608 )
  453.     ROM_LOAD( "epr1264.rom",  0x4000, 0x2000, 0x1802f6c7 )
  454.  
  455.     ROM_REGION( 0x20000, REGION_GFX1 ) /* sprite data */
  456.     ROM_LOAD( "epr1246.rom", 0x00000, 0x2000, 0x555bfe9a )
  457.     ROM_RELOAD(                 0x02000, 0x2000 )
  458.     ROM_LOAD( "epr1247.rom", 0x04000, 0x2000, 0xc8c5e4d5 )
  459.     ROM_RELOAD(                 0x06000, 0x2000 )
  460.     ROM_LOAD( "epr1248.rom", 0x08000, 0x2000, 0x82fe5b94 )
  461.     ROM_RELOAD(                 0x0a000, 0x2000 )
  462.     ROM_LOAD( "epr1249.rom", 0x0c000, 0x2000, 0xe258e009 )
  463.     ROM_LOAD( "epr1250.rom", 0x0e000, 0x2000, 0xaee6e05e )
  464.     ROM_LOAD( "epr1251.rom", 0x10000, 0x2000, 0x292573de )
  465.     ROM_LOAD( "epr1252.rom", 0x12000, 0x2000, 0xaee6e05e )
  466.     ROM_LOAD( "epr1253.rom", 0x14000, 0x2000, 0x92783626 )
  467.     ROM_LOAD( "epr1254.rom", 0x16000, 0x2000, 0xaee6e05e )
  468.     ROM_LOAD( "epr1255.rom", 0x18000, 0x2000, 0x485dcef9 )
  469.     ROM_LOAD( "epr1256.rom", 0x1a000, 0x2000, 0xaee6e05e )
  470.     ROM_LOAD( "epr1257.rom", 0x1c000, 0x2000, 0x4ca984ce )
  471.     ROM_LOAD( "epr1258.rom", 0x1e000, 0x2000, 0xaee6e05e )
  472.  
  473.     ROM_REGION( 0x4800, REGION_GFX2 ) /* road data */
  474.     ROM_LOAD( "epr1125.rom", 0x0000, 0x0800, 0x65b5d44b )
  475.     ROM_LOAD( "epr1126.rom", 0x0800, 0x0800, 0x685ace1b )
  476.     ROM_LOAD( "epr1127.rom", 0x1000, 0x0800, 0x9233c9ca )
  477.     ROM_LOAD( "epr1238.rom", 0x1800, 0x0800, 0xd94fd83f )
  478.     ROM_LOAD( "epr1239.rom", 0x2000, 0x0800, 0x4c41124f )
  479.     ROM_LOAD( "epr1240.rom", 0x2800, 0x0800, 0x371d6282 )
  480.     ROM_LOAD( "epr1241.rom", 0x3000, 0x0800, 0x1109358a )
  481.     ROM_LOAD( "epr1242.rom", 0x3800, 0x0800, 0x04866769 )
  482.     ROM_LOAD( "epr1243.rom", 0x4000, 0x0800, 0x29854c48 )
  483.  
  484.     ROM_REGION( 0x1000, REGION_GFX3 )    /* background data */
  485.     ROM_LOAD( "epr1244.rom", 0x0000, 0x0800, 0x17f67424 )
  486.     ROM_LOAD( "epr1245.rom", 0x0800, 0x0800, 0x2ba0b46b )
  487.  
  488.     ROM_REGION( 0x200, REGION_GFX4 )    /* number data (copied at init time) */
  489.  
  490.  
  491.     ROM_REGION( 0x1000, REGION_PROMS ) /* various PROMs */
  492.     ROM_LOAD( "pr1121.bin",     0x0000, 0x0200, 0x7692f497 )    /* palette */
  493.     ROM_LOAD( "pr1122.bin",     0x0200, 0x0400, 0x1a86ce70 )    /* sprite priorities */
  494.     ROM_LOAD( "pr1123.bin",     0x0600, 0x0400, 0x02d2cb52 )    /* sprite/road/background priorities */
  495.     ROM_LOAD( "pr-1118.bin", 0x0a00, 0x0100, 0x07324cfd )    /* background color table */
  496.     ROM_LOAD( "pr1114.bin",     0x0b00, 0x0020, 0x78aded46 )    /* road red/green color table */
  497.     ROM_LOAD( "pr1117.bin",     0x0b20, 0x0020, 0xf06d9907 )    /* road green/blue color table */
  498.     ROM_LOAD( "pr1115.bin",     0x0b40, 0x0020, 0x5394092c )    /* road collision/enable */
  499.     ROM_LOAD( "pr1116.bin",     0x0b60, 0x0020, 0x3956767d )    /* collision detection */
  500.     ROM_LOAD( "sndprom.bin", 0x0b80, 0x0020, 0xb369a6ae )
  501.     ROM_LOAD( "pr-1119.bin", 0x0c00, 0x0200, 0x628d3f1d )    /* timing - not used */
  502.     ROM_LOAD( "pr-1120.bin", 0x0e00, 0x0200, 0x591b6a68 )    /* timing - not used */
  503. ROM_END
  504.  
  505. ROM_START( turbob )
  506.     ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */
  507.     ROM_LOAD( "epr-1363.cpu",  0x0000, 0x2000, 0x5c110fb6 )
  508.     ROM_LOAD( "epr-1364.cpu",  0x2000, 0x2000, 0x6a341693 )
  509.     ROM_LOAD( "epr-1365.cpu",  0x4000, 0x2000, 0x3b6b0dc8 )
  510.  
  511.     ROM_REGION( 0x20000, REGION_GFX1 ) /* sprite data */
  512.     ROM_LOAD( "epr1246.rom", 0x00000, 0x2000, 0x555bfe9a )
  513.     ROM_RELOAD(                 0x02000, 0x2000 )
  514.     ROM_LOAD( "mpr1290.rom", 0x04000, 0x2000, 0x95182020 )    /* is this good? */
  515.     ROM_RELOAD(                 0x06000, 0x2000 )
  516.     ROM_LOAD( "epr1248.rom", 0x08000, 0x2000, 0x82fe5b94 )
  517.     ROM_RELOAD(                 0x0a000, 0x2000 )
  518.     ROM_LOAD( "mpr1291.rom", 0x0c000, 0x2000, 0x0e857f82 )    /* is this good? */
  519.     ROM_LOAD( "epr1250.rom", 0x0e000, 0x2000, 0xaee6e05e )
  520.     ROM_LOAD( "epr1251.rom", 0x10000, 0x2000, 0x292573de )
  521.     ROM_LOAD( "epr1252.rom", 0x12000, 0x2000, 0xaee6e05e )
  522.     ROM_LOAD( "epr1253.rom", 0x14000, 0x2000, 0x92783626 )
  523.     ROM_LOAD( "epr1254.rom", 0x16000, 0x2000, 0xaee6e05e )
  524.     ROM_LOAD( "epr1255.rom", 0x18000, 0x2000, 0x485dcef9 )
  525.     ROM_LOAD( "epr1256.rom", 0x1a000, 0x2000, 0xaee6e05e )
  526.     ROM_LOAD( "epr1257.rom", 0x1c000, 0x2000, 0x4ca984ce )
  527.     ROM_LOAD( "epr1258.rom", 0x1e000, 0x2000, 0xaee6e05e )
  528.  
  529.     ROM_REGION( 0x4800, REGION_GFX2 ) /* road data */
  530.     ROM_LOAD( "epr1125.rom", 0x0000, 0x0800, 0x65b5d44b )
  531.     ROM_LOAD( "epr1126.rom", 0x0800, 0x0800, 0x685ace1b )
  532.     ROM_LOAD( "epr1127.rom", 0x1000, 0x0800, 0x9233c9ca )
  533.     ROM_LOAD( "epr1238.rom", 0x1800, 0x0800, 0xd94fd83f )
  534.     ROM_LOAD( "epr1239.rom", 0x2000, 0x0800, 0x4c41124f )
  535.     ROM_LOAD( "epr1240.rom", 0x2800, 0x0800, 0x371d6282 )
  536.     ROM_LOAD( "epr1241.rom", 0x3000, 0x0800, 0x1109358a )
  537.     ROM_LOAD( "epr1242.rom", 0x3800, 0x0800, 0x04866769 )
  538.     ROM_LOAD( "epr1243.rom", 0x4000, 0x0800, 0x29854c48 )
  539.  
  540.     ROM_REGION( 0x1000, REGION_GFX3 )    /* background data */
  541.     ROM_LOAD( "epr1244.rom", 0x0000, 0x0800, 0x17f67424 )
  542.     ROM_LOAD( "epr1245.rom", 0x0800, 0x0800, 0x2ba0b46b )
  543.  
  544.     ROM_REGION( 0x200, REGION_GFX4 )    /* number data (copied at init time) */
  545.  
  546.  
  547.     ROM_REGION( 0x1000, REGION_PROMS ) /* various PROMs */
  548.     ROM_LOAD( "pr1121.bin",     0x0000, 0x0200, 0x7692f497 )    /* palette */
  549.     ROM_LOAD( "pr1122.bin",     0x0200, 0x0400, 0x1a86ce70 )    /* sprite priorities */
  550.     ROM_LOAD( "pr1123.bin",     0x0600, 0x0400, 0x02d2cb52 )    /* sprite/road/background priorities */
  551.     ROM_LOAD( "pr-1118.bin", 0x0a00, 0x0100, 0x07324cfd )    /* background color table */
  552.     ROM_LOAD( "pr1114.bin",     0x0b00, 0x0020, 0x78aded46 )    /* road red/green color table */
  553.     ROM_LOAD( "pr1117.bin",     0x0b20, 0x0020, 0xf06d9907 )    /* road green/blue color table */
  554.     ROM_LOAD( "pr1115.bin",     0x0b40, 0x0020, 0x5394092c )    /* road collision/enable */
  555.     ROM_LOAD( "pr1116.bin",     0x0b60, 0x0020, 0x3956767d )    /* collision detection */
  556.     ROM_LOAD( "sndprom.bin", 0x0b80, 0x0020, 0xb369a6ae )
  557.     ROM_LOAD( "pr-1119.bin", 0x0c00, 0x0200, 0x628d3f1d )    /* timing - not used */
  558.     ROM_LOAD( "pr-1120.bin", 0x0e00, 0x0200, 0x591b6a68 )    /* timing - not used */
  559. ROM_END
  560.  
  561.  
  562. /*********************************************************************
  563.  * ROM decoding
  564.  *********************************************************************/
  565.  
  566. static void rom_decode(void)
  567. {
  568. /*
  569.  * The table is arranged this way (second half is mirror image of first)
  570.  *
  571.  *        0  1  2     3    4  5  6     7    8  9  A     B    C  D  E     F
  572.  *
  573.  * 0   00 00 00 00 01 01 01 01 02 02 02 02 03 03 03 03
  574.  * 1   04 04 04 04 05 05 05 05 06 06 06 06 07 07 07 07
  575.  * 2   08 08 08 08 09 09 09 09 0A 0A 0A 0A 0B 0B 0B 0B
  576.  * 3   0C 0C 0C 0C 0D 0D 0D 0D 0E 0E 0E 0E 0F 0F 0F 0F
  577.  * 4   10 10 10 10 11 11 11 11 12 12 12 12 13 13 13 13
  578.  * 5   14 14 14 14 15 15 15 15 16 16 16 16 17 17 17 17
  579.  * 6   18 18 18 18 19 19 19 19 1A 1A 1A 1A 1B 1B 1B 1B
  580.  * 7   1C 1C 1C 1C 1D 1D 1D 1D 1E 1E 1E 1E 1F 1F 1F 1F
  581.  * 8   1F 1F 1F 1F 1E 1E 1E 1E 1D 1D 1D 1D 1C 1C 1C 1C
  582.  * 9   1B 1B 1B 1B 1A 1A 1A 1A 19 19 19 19 18 18 18 18
  583.  * A   17 17 17 17 16 16 16 16 15 15 15 15 14 14 14 14
  584.  * B   13 13 13 13 12 12 12 12 11 11 11 11 10 10 10 10
  585.  * C   0F 0F 0F 0F 0E 0E 0E 0E 0D 0D 0D 0D 0C 0C 0C 0C
  586.  * D   0B 0B 0B 0B 0A 0A 0A 0A 09 09 09 09 08 08 08 08
  587.  * E   07 07 07 07 06 06 06 06 05 05 05 05 04 04 04 04
  588.  * F   03 03 03 03 02 02 02 02 01 01 01 01 00 00 00 00
  589.  *
  590.  */
  591.  
  592.     static const UINT8 xortable[4][32]=
  593.     {
  594.         /* Table 0 */
  595.         /* 0x0000-0x3ff */
  596.         /* 0x0800-0xbff */
  597.         /* 0x4000-0x43ff */
  598.         /* 0x4800-0x4bff */
  599.         { 0x00,0x44,0x0c,0x48,0x00,0x44,0x0c,0x48,
  600.           0xa0,0xe4,0xac,0xe8,0xa0,0xe4,0xac,0xe8,
  601.           0x60,0x24,0x6c,0x28,0x60,0x24,0x6c,0x28,
  602.           0xc0,0x84,0xcc,0x88,0xc0,0x84,0xcc,0x88 },
  603.  
  604.         /* Table 1 */
  605.         /* 0x0400-0x07ff */
  606.         /* 0x0c00-0x0fff */
  607.         /* 0x1400-0x17ff */
  608.         /* 0x1c00-0x1fff */
  609.         /* 0x2400-0x27ff */
  610.         /* 0x2c00-0x2fff */
  611.         /* 0x3400-0x37ff */
  612.         /* 0x3c00-0x3fff */
  613.         /* 0x4400-0x47ff */
  614.         /* 0x4c00-0x4fff */
  615.         /* 0x5400-0x57ff */
  616.         /* 0x5c00-0x5fff */
  617.         { 0x00,0x44,0x18,0x5c,0x14,0x50,0x0c,0x48,
  618.           0x28,0x6c,0x30,0x74,0x3c,0x78,0x24,0x60,
  619.           0x60,0x24,0x78,0x3c,0x74,0x30,0x6c,0x28,
  620.           0x48,0x0c,0x50,0x14,0x5c,0x18,0x44,0x00 }, //0x00 --> 0x10 ?
  621.  
  622.         /* Table 2 */
  623.         /* 0x1000-0x13ff */
  624.         /* 0x1800-0x1bff */
  625.         /* 0x5000-0x53ff */
  626.         /* 0x5800-0x5bff */
  627.         { 0x00,0x00,0x28,0x28,0x90,0x90,0xb8,0xb8,
  628.           0x28,0x28,0x00,0x00,0xb8,0xb8,0x90,0x90,
  629.           0x00,0x00,0x28,0x28,0x90,0x90,0xb8,0xb8,
  630.           0x28,0x28,0x00,0x00,0xb8,0xb8,0x90,0x90 },
  631.  
  632.         /* Table 3 */
  633.         /* 0x2000-0x23ff */
  634.         /* 0x2800-0x2bff */
  635.         /* 0x3000-0x33ff */
  636.         /* 0x3800-0x3bff */
  637.         { 0x00,0x14,0x88,0x9c,0x30,0x24,0xb8,0xac,
  638.           0x24,0x30,0xac,0xb8,0x14,0x00,0x9c,0x88,
  639.           0x48,0x5c,0xc0,0xd4,0x78,0x6c,0xf0,0xe4,
  640.           0x6c,0x78,0xe4,0xf0,0x5c,0x48,0xd4,0xc0 }
  641.     };
  642.  
  643.     int findtable[]=
  644.     {
  645.         0,1,0,1, /* 0x0000-0x0fff */
  646.         2,1,2,1, /* 0x1000-0x1fff */
  647.         3,1,3,1, /* 0x2000-0x2fff */
  648.         3,1,3,1, /* 0x3000-0x3fff */
  649.         0,1,0,1, /* 0x4000-0x4fff */
  650.         2,1,2,1     /* 0x5000-0x5fff */
  651.     };
  652.  
  653.     UINT8 *RAM = memory_region(REGION_CPU1);
  654.     int offs, i, j;
  655.     UINT8 src;
  656.  
  657.     for (offs = 0x0000; offs < 0x6000; offs++)
  658.     {
  659.         src = RAM[offs];
  660.         i = findtable[offs >> 10];
  661.         j = src >> 2;
  662.         if (src & 0x80) j ^= 0x3f;
  663.         RAM[offs] = src ^ xortable[i][j];
  664.     }
  665. }
  666.  
  667.  
  668. /*********************************************************************
  669.  * Driver init
  670.  *********************************************************************/
  671.  
  672. static void init_turbo(void)
  673. {
  674.     static const UINT8 led_number_data[] =
  675.     {
  676.         0x3e,0x41,0x41,0x41,0x00,0x41,0x41,0x41,0x3e,0x00,
  677.         0x00,0x01,0x01,0x01,0x00,0x01,0x01,0x01,0x00,0x00,
  678.         0x3e,0x01,0x01,0x01,0x3e,0x40,0x40,0x40,0x3e,0x00,
  679.         0x3e,0x01,0x01,0x01,0x3e,0x01,0x01,0x01,0x3e,0x00,
  680.         0x00,0x41,0x41,0x41,0x3e,0x01,0x01,0x01,0x00,0x00,
  681.         0x3e,0x40,0x40,0x40,0x3e,0x01,0x01,0x01,0x3e,0x00,
  682.         0x3e,0x40,0x40,0x40,0x3e,0x41,0x41,0x41,0x3e,0x00,
  683.         0x3e,0x01,0x01,0x01,0x00,0x01,0x01,0x01,0x00,0x00,
  684.         0x3e,0x41,0x41,0x41,0x3e,0x41,0x41,0x41,0x3e,0x00,
  685.         0x3e,0x41,0x41,0x41,0x3e,0x01,0x01,0x01,0x3e,0x00
  686.     };
  687.  
  688.     static const UINT8 led_tach_data[] =
  689.     {
  690.         0xff,0x00
  691.     };
  692.  
  693.     memset(memory_region(REGION_GFX4), 0, memory_region_length(REGION_GFX4));
  694.     memcpy(memory_region(REGION_GFX4), led_number_data, sizeof(led_number_data));
  695.     memcpy(memory_region(REGION_GFX4)+0x100, led_tach_data, sizeof(led_tach_data));
  696. }
  697.  
  698. static void init_decode_turbo(void)
  699. {
  700.     init_turbo();
  701.     rom_decode();
  702. }
  703.  
  704.  
  705. /*********************************************************************
  706.  * Game drivers
  707.  *********************************************************************/
  708.  
  709. GAMEX( 1981, turbo,  0,     turbo, turbo, turbo,        ROT270, "Sega", "Turbo", GAME_NO_COCKTAIL )
  710. GAMEX( 1981, turboa, turbo, turbo, turbo, decode_turbo, ROT270, "Sega", "Turbo (encrypted set 1)", GAME_NO_COCKTAIL )
  711. GAMEX( 1981, turbob, turbo, turbo, turbo, decode_turbo, ROT270, "Sega", "Turbo (encrypted set 2)", GAME_NO_COCKTAIL )
  712.